// 笔试强训day34:kotori和迷宫

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int n, m; 
    cin >> n >> m;
    vector<vector<char>> Map(n, vector<char>(m));
    vector<vector<int>> Val(n, vector<int>(m, -1));
    queue<pair<int, int>> q;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cin >> Map[i][j];
            if(Map[i][j] == 'k')
            {
                q.push({i, j});
                Val[i][j] = 0;
            }
        }
    }

    vector<int> dx = {0, 0, -1, 1};
    vector<int> dy = {-1, 1, 0, 0};
    int count = 0, minLen = 0;
    while(!q.empty())
    {
        pair<int, int> cur = q.front();
        q.pop();
        if(Map[cur.first][cur.second] == 'e')
        {
            count++;
            if(minLen == 0) minLen = Val[cur.first][cur.second];
            continue;
        }
        for(int i = 0; i < 4; i++)
        {
            int x = cur.first + dx[i];
            int y = cur.second + dy[i];
            if(x >= 0 && x < n && y >= 0 && y < m && Map[x][y] != '*' && Val[x][y] == -1)
            {
                q.push({x, y});
                Val[x][y] = Val[cur.first][cur.second] + 1;
            }
        }
    }
    if(count == 0)
        cout << -1 << endl;
    else
        cout << count << " " << minLen << endl;
}